package com.situ.day7;

public class Student extends Person{
//    private int id;
//    private String name;
//    private int age;
    //特有的
    private String className;

    public Student(String className) {
        //new Person()
        super();
        this.className = className;
    }

    //在Java里面new子类对象的时候一定首先new出父类对象
    public Student(int id, String name, int age, String className) {
        //new Person(int id, String name, int age)
        super(id, name, age);
        //子类继承父类属性，相当于子类有这些属性
        //super();
        //this.id = id;
        //this.name = name;
        //this.age = age;
        this.className = className;
    }

    public void study() {
        System.out.println(name + "正在学习");
    }


    @Override
    public void show() {
        //super()
        //this:当前类对象
        //super:代表父类对象
        //super.show();
        System.out.println("Student.show");
    }

    //重写（也叫覆盖）：从父类继承的方法，子类不满意，重新按照子类的需求实现了这个方法
    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", className='" + className + '\'' +
                '}';
    }
}
